/*
Copyright (C) 2010  Christoph Schnack, Berlin (Germany)

This file is part of Tribuit.

    Tribuit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Tribuit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Tribuit.  If not, see <http://www.gnu.org/licenses/>.
*/
package PictureDescription;

import java.awt.*;
import java.util.*;

/**
 * Keeps information about the tag marking the space in the picture. In the center is the index's number. Around it lines can be arranged, whose positions are held in a vector of Points. 
 * @author Christoph Schnack
 *
 */
public class PictureTagUnit {

	Vector<TADE> tades;
	Point centerPosition;
	Color color,bgColor,bgHighlightColor;
	int radius;
	
	/**
	 * 
	 * @param pnts for the vector arms
	 * @param center center position
	 * @param col shape's color
	 * @param bgCol background color
	 */
	public PictureTagUnit(Vector<TADE> pnts,Point center, Color col,Color bgCol,Color bgHighlightCol,int rad){
		tades=pnts==null?new Vector<TADE>():pnts;
		centerPosition = center;
		color=col;
		bgColor=bgCol;
		bgHighlightColor=bgHighlightCol;
		radius=rad;
	}
		
	public int getRadius(){
		return radius;
	}
	
	public void setRadius(int r){
		radius=r;
	}
	
//START CenterPoint section	
	
	public Point getCenterPosition(){
		return centerPosition;
	}
	
	public void setCenterPosition(Point point){
		if(point!=null)centerPosition=point;
	}
//END CenterPoint section
		
//START arms' points section
	
	public TADE getPictureTag(int index){
		return tades.elementAt(index);
	}

	/**
	 * Adds an arm's position.
	 * @param point
	 */
	public void addPictureTagRelated(String type,Point point,Color color,Color fColor){
		if(point!=null&&type!=null){
			tades.add(new TADE(type,point,color,fColor));
		}
	}
	
	public void addPictureTagAbsolute(String type,Point point,Color color,Color fColor){
		if(point!=null&&type!=null){
			tades.add(new TADE(type,new Point(point.x-centerPosition.x,point.y-centerPosition.y),color,fColor));
		}
	}
	
	public void deleteTADEAt(int i){
		if(tades!=null && tades.size()>=i-1)tades.remove(i);
	}
	
	public void deleteAllTADEs(){
		tades = new Vector<TADE>();
	}
	
//END arms' points section
	
//START Color section
	public Color getColor(){
		return color;
	}
	public void setColor(Color c){
		color=c;
	}
	
	public Color getBgColor(){
		return bgColor;
	}
	public void setBgColor(Color c){
		bgColor=c;
	}
	
	public Color getBgHlColor(){
		return bgHighlightColor;
	}
	public void setBgHlColor(Color c){
		bgHighlightColor=c;
	}
	
//END Color section
	
	public Vector<TADE> getPictureTags(){
		return tades;
	}
	
	public boolean hasTADEs(){
		return tades.size()>0;
	}
	
	public void replaceTade(int i,TADE tade){
		if(tades!=null && tades.size()>=i-1)tades.set(i, tade);
	}
}
